package entity

import (
	common_entity "trpg-common/entity"
	"trpg-common/utils/time_util"
)

type Message struct {
	Id          int64           `gorm:"column:id;primaryKey" json:"id"`
	IsDeleted   string          `gorm:"column:is_deleted;default:N" json:"isDeleted" form:"isDeleted"`
	Creator     string          `gorm:"column:creator" json:"senderId" form:"creator"`
	Modifier    string          `gorm:"column:modifier" json:"modifier" form:"modifier"`
	GmtCreated  *time_util.Time `gorm:"column:gmt_created" json:"gmtCreated"`
	GmtModified *time_util.Time `gorm:"column:gmt_modified" json:"gmtModified"`
	RoomId      int64           `gorm:"column:room_id" json:"roomId"`
	CreatorName string          `gorm:"-" json:"username"`
	Avatar      string          `gorm:"-" json:"avatar"`
	Content     string          `gorm:"column:content" json:"content"`
	Files       []File          `gorm:"-" json:"files"`
	FilesStr    string          `gorm:"column:files" json:"filesStr"`
	TimeStamp   string          `gorm:"-" json:"timeStamp"`
	Date        string          `gorm:"-" json:"date"`
}

func (Message) TableName() string {
	return "room_message"
}

type File struct {
	Name string `json:"name"`
	Type string `json:"type"`
	Url  string `json:"url"`
	Path string `json:"path"`
}

type Room struct {
	common_entity.BaseEntity
	Name         string `gorm:"column:name" json:"name" form:"name"`
	Description  string `gorm:"column:description" json:"description" form:"description"`
	Admin        string `gorm:"admin" json:"admin" form:"admin"`
	LabelIds     string `gorm:"column:label_ids" json:"labelIds" form:"labelIds"` // 标签id
	CoverKey     string `gorm:"column:cover_key" json:"coverKey"`
	BotOn        bool   `gorm:"column:bot_on" json:"botOn"`
	GreatSuccess int32  `gorm:"column:great_success" json:"-"`
	GreatFail    int32  `gorm:"column:great_fail" json:"-"`
}

func (Room) TableName() string {
	return "room"
}

type RoomUser struct {
	common_entity.BaseEntity
	RoomId      int64  `gorm:"column:room_id" json:"roomId"`
	Uid         string `gorm:"column:uid" json:"uid"`
	Status      int32  `gorm:"column:status" json:"status"`
	CharacterId int64  `gorm:"column:character_id" json:"characterId"`
}

func (RoomUser) TableName() string {
	return "room_user"
}

type Character struct {
	common_entity.BaseEntity
	Uid               string `gorm:"column:uid" json:"uid"`
	CharacterName     string `gorm:"column:character_name" json:"characterName"`
	Name              string `gorm:"column:name" json:"name"`
	RememberedVarsStr string `gorm:"column:remembered_vars_str" json:"rememberedVars"`
	RememberedVars    string `gorm:"column:remembered_vars" json:"-"`
	ExcelUrl          string `gorm:"-" json:"excelUrl"`
	ExcelPath         string `gorm:"column:excel_path" json:"excelPath"`
}

func (Character) TableName() string {
	return "character"
}
